# -*- coding: utf-8 -*-
#
# File: ARFilePreview/Extensions/Install.py
#
# 

"""
$Id$
"""

__author__ = """Jean-Nicolas Bès <contact@atreal.net>"""
__docformat__ = 'plaintext'
__licence__ = 'GPL'


from StringIO import StringIO
from Products.ARFilePreview.config    import *
from Products.Archetypes.Extensions.utils import install_subskin

def install(self):
    """
    Install ARFilePreview
    """
    out = StringIO()
    pt = self.portal_types
    pt['File'].default_view = "file_preview"
    pt['File'].immediate_view = "file_preview"
    pt['File'].view_methods = ("file_preview", "file_asdoc")
    install_subskin(self, out, GLOBALS)
    print "installed ARFilePreview"
    return out.getvalue()


def uninstall(self):
    out = StringIO()
    pt = self.portal_types
    pt['File'].default_view = "file_view"
    pt['File'].immediate_view = "file_view"
##    avViews = ["file_view"]
##    for view in pt['File'].view_methods:
##        if view in ["file_preview", "file_asdoc"]:
##            continue
##        avViews.append(view)
##    pt['File'].view_methods = tuple(avViews)
    pt['File'].view_methods = ("file_view",)
    return out.getvalue()
